<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <SONIA ZRIBI>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <SONIA ZRIBI>
 */
class Application_Model_TuteurHasCourselot extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_TuteurCin;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_CourselotIdcourselot;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_IdTuteurHasCourselot;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Idgroupe;


    /**
     * Parent relation fk_tuteur_has_courselot_courselot1
     *
     * @var Application_Model_Course
     */
    protected $_Course;

    /**
     * Parent relation fk_tuteur_has_courselot_groupe1
     *
     * @var Application_Model_Groupe
     */
    protected $_Groupe;

    /**
     * Parent relation fk_tuteur_has_courselot_tuteur1
     *
     * @var Application_Model_Tuteur
     */
    protected $_Tuteur;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'tuteur_cin'=>'TuteurCin',
            'courselot_idcourselot'=>'CourselotIdcourselot',
            'id_tuteur_has_courselot'=>'IdTuteurHasCourselot',
            'idgroupe'=>'Idgroupe',
        ));

        $this->setParentList(array(
            'FkTuteurHasCourselotCourselot1'=> array(
                    'property' => 'Course',
                    'table_name' => 'Course',
                ),
            'FkTuteurHasCourselotGroupe1'=> array(
                    'property' => 'Groupe',
                    'table_name' => 'Groupe',
                ),
            'FkTuteurHasCourselotTuteur1'=> array(
                    'property' => 'Tuteur',
                    'table_name' => 'Tuteur',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column tuteur_cin
     *
     * @param int $data
     * @return Application_Model_TuteurHasCourselot
     */
    public function setTuteurCin($data)
    {
        $this->_TuteurCin = $data;
        return $this;
    }

    /**
     * Gets column tuteur_cin
     *
     * @return int
     */
    public function getTuteurCin()
    {
        return $this->_TuteurCin;
    }

    /**
     * Sets column courselot_idcourselot
     *
     * @param int $data
     * @return Application_Model_TuteurHasCourselot
     */
    public function setCourselotIdcourselot($data)
    {
        $this->_CourselotIdcourselot = $data;
        return $this;
    }

    /**
     * Gets column courselot_idcourselot
     *
     * @return int
     */
    public function getCourselotIdcourselot()
    {
        return $this->_CourselotIdcourselot;
    }

    /**
     * Sets column id_tuteur_has_courselot
     *
     * @param int $data
     * @return Application_Model_TuteurHasCourselot
     */
    public function setIdTuteurHasCourselot($data)
    {
        $this->_IdTuteurHasCourselot = $data;
        return $this;
    }

    /**
     * Gets column id_tuteur_has_courselot
     *
     * @return int
     */
    public function getIdTuteurHasCourselot()
    {
        return $this->_IdTuteurHasCourselot;
    }

    /**
     * Sets column idgroupe
     *
     * @param string $data
     * @return Application_Model_TuteurHasCourselot
     */
    public function setIdgroupe($data)
    {
        $this->_Idgroupe = $data;
        return $this;
    }

    /**
     * Gets column idgroupe
     *
     * @return string
     */
    public function getIdgroupe()
    {
        return $this->_Idgroupe;
    }

    /**
     * Sets parent relation CourselotIdcourselot
     *
     * @param Application_Model_Course $data
     * @return Application_Model_TuteurHasCourselot
     */
    public function setCourse(Application_Model_Course $data)
    {
        $this->_Course = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idcourse'];
        }

        $this->setCourselotIdcourselot($primary_key);

        return $this;
    }

    /**
     * Gets parent CourselotIdcourselot
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Course
     */
    public function getCourse($load = true)
    {
        if ($this->_Course === null && $load) {
            $this->getMapper()->loadRelated('FkTuteurHasCourselotCourselot1', $this);
        }

        return $this->_Course;
    }

    /**
     * Sets parent relation Idgroupe
     *
     * @param Application_Model_Groupe $data
     * @return Application_Model_TuteurHasCourselot
     */
    public function setGroupe(Application_Model_Groupe $data)
    {
        $this->_Groupe = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idgroupe'];
        }

        $this->setIdgroupe($primary_key);

        return $this;
    }

    /**
     * Gets parent Idgroupe
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Groupe
     */
    public function getGroupe($load = true)
    {
        if ($this->_Groupe === null && $load) {
            $this->getMapper()->loadRelated('FkTuteurHasCourselotGroupe1', $this);
        }

        return $this->_Groupe;
    }

    /**
     * Sets parent relation TuteurCin
     *
     * @param Application_Model_Tuteur $data
     * @return Application_Model_TuteurHasCourselot
     */
    public function setTuteur(Application_Model_Tuteur $data)
    {
        $this->_Tuteur = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['cin'];
        }

        $this->setTuteurCin($primary_key);

        return $this;
    }

    /**
     * Gets parent TuteurCin
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Tuteur
     */
    public function getTuteur($load = true)
    {
        if ($this->_Tuteur === null && $load) {
            $this->getMapper()->loadRelated('FkTuteurHasCourselotTuteur1', $this);
        }

        return $this->_Tuteur;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_TuteurHasCourselot
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_TuteurHasCourselot());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_TuteurHasCourselot::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdTuteurHasCourselot() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_tuteur_has_courselot = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdTuteurHasCourselot()));
    }
}
